﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hopscotch.Common.Contracts.AppService;
using Hopscotch.Domain.Enquiry;
using Hopscotch.Domain.Finance;

namespace Hopscotch.Server.Common
{
    public class TradeEnricher
    {
        private readonly IInstrumentService instrumentService;

        public TradeEnricher(IInstrumentService instrumentService)
        {
            this.instrumentService = instrumentService;
        }

        public TradeEnq Enrich(Trade trade)
        {
            var tradeEnq = new TradeEnq(trade);

            if (tradeEnq.InstrumentId.HasValue)
            {
                var equity = instrumentService.Get(trade.InstrumentId.Value) as EquityInstrument;
                if (equity != null)
                    tradeEnq.TradeCcy = equity.DefaultCurrency;
            }
            return tradeEnq;
        }
    }
}
